package com.happyclub.utils;

import sun.misc.BASE64Encoder;

import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

/**
 * @author  魏泉琦
 * @return  加密后的字符串  对字符串进行加密
 * @throws NoSuchAlgorithmException  没有这种产生消息摘要的算法
 * @throws UnsupportedEncodingException
 */
public class Md5Utits {
    public static String EncoderByMd5(String str) throws Exception {
        //确定算法
        MessageDigest md5 = MessageDigest.getInstance("MD5");
        BASE64Encoder base64en = new BASE64Encoder();
        //加密后的字符串
        String newstr = base64en.encode(md5.digest(str.getBytes("utf-8")));
        return newstr;
    }
}